package com.lfy.ai;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ResourceUtils;

import java.io.File;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
 * Ai模型key管理类
 *
 * @author <a href="https://www.lvfeiy.top">lvfeiyang</a>
 * @date 2024/6/23 2:11
 */
@Slf4j
public class Key {
    public static Map<String,String> keyMap = new HashMap<>(16);
    static {
        try {
            File file = ResourceUtils.getFile("classpath:AiKey.properties");
            Properties properties = new Properties();

            properties.load(file.toURI().toURL().openStream());
            for (Object o : properties.keySet()) {
                String key = (String) o;
                String value = properties.getProperty(key);
                keyMap.put(key, value);
            }
        } catch (Exception e) {
            log.error("in com.lfy.ai.Key.static load AiKey.properties error", e);
        }

    }
    public static String get(String key) {
        return keyMap.get(key);
    }

}
